<?php 

	if (isset($_GET['alert']) && !empty($_GET['alert'])) {
		$alert =$_GET['alert'];
		echo "<script type='text/javascript'>alert('$alert');</script>";
	}

	$sql = "SELECT * FROM funcionario ORDER BY dt_inscricao DESC";
	$resultado = mysql_query($sql);
?>
 <html>
 <head>
 <script type="text/javascript">
 	function paint (id) {
		
		for (var i = 0; i < id; i++) {
			if (i % 2 == 0) {
				document.getElementById(i).style.backgroundColor='#E6F9F7';
			}else{
				document.getElementById(i).style.backgroundColor='#BED6F4';
			}
		}
	}

	function excluir(id){
		var resp = confirm("Deseja 	realmente exluir o registro ?");

		if(resp){
			location.href="index.php?page=funcionario/excluirfuncionario.php&id="+id;
		}
	}
 </script>
 </head>

 <body>
	<div class="flist"> 
								
	 	<table class="tabela">
			<tr><th>Matricula</th><th>Nome</th><th>Função</th><th>Data de Inscrição</th><th>Opções</th></tr>
	  				<?php $i = 0;?>
			<?php 	while($arrayResult = mysql_fetch_assoc($resultado)): ?>	
					<tr id="<?php echo $i; ?>">
						<td><?php echo $arrayResult['matricula']; ?></td>
						<td><?php echo $arrayResult['no_funcionario']; ?></td>
						<td><?php echo $arrayResult['idfuncao']; ?></td>
						<td><?php echo $arrayResult['dt_inscricao']; ?></td>
						<td>
							<a href="index.php?page=funcionario/editarfuncionario.php&id=<?php echo $arrayResult['matricula']?>">
								  <img src="imagens/pen2.png" height="32" width="32"/>
							</a> &nbsp &nbsp	
							<a href="#" onClick='excluir(<?php echo $arrayResult['matricula']; ?>)'>
								  <img src="imagens/exc.png" height="32" width="32" />
							</a>	
						</td>
					</tr>
					<?php $i++; ?>
		
			<?php endwhile; ?>
			<script type="text/javascript">
				var i = '<?php echo $i; ?>'; 
				paint(i);
			</script>
		</table>
	</div>
 </body>
 </html>